<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>图书列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/application.css"></c:url>">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/listdata.css"></c:url>">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/form.css"></c:url>">
    
    <script type="text/javascript" src="<c:url value="/js/common.js"/>"></script>

    <script type="text/javascript">
         function updateBook(id){
           
           location.href="<c:url value="/bookMgr?act=preModify&bookcode="/>"+id;
         }
    
    
         function removeBook(id,name)
         {
            //alert("you delete book name:"+name+",id="+id);
            if(confirm("您真的确认要删除图书["+name+"]")){
               location.href="<c:url value="/bookMgr?act=remove&bookcode="/>"+id;
            }
         }
         
         
          function doQuery(pageno)
         {
            if(pageno<1 || pageno>${page.totalPageNum})
            {
              alert("页号超出范围，有效范围：[1-${page.totalPageNum}]!");
              ${'pageNo'}.select();
              return;
            }
            
            var f=document.forms[0];
            f.action=f.action+"?pageNo="+pageno;
            f.submit();
            
         }
         
         function PriceSequence(type){
            var p = document.forms[0];
            p.action=p.action+"?PriceSequence="+type;
            p.submit();
         
         }
    
    </script>

  </head>
  
  <body>
     <div class="listTitle"> 
      >> 图书列表
    </div>
    <c:if test="${not empty page.pageContent}">
    <form action="<c:url value="/bookMgr"/>" method="post">
    <input type="hidden" name="act" value="qryloadall">
     <div>
                     图书编号：<input type="text" class="text" name="qryBookCode" size="20" value="${param['qryBookCode']}"/>&nbsp;&nbsp;
                     图书名称：<input type="text" class="text" name="qryBookName" size="20" value="${param['qryBookName']}"/>&nbsp;&nbsp;
                      出版社：<input type="text" class="text" name="qryBookPublisher" size="20" value="${param['qryBookPublisher']}"/>&nbsp;&nbsp;
                     图书类别：<select name="qryBookCtg" >
	            <option value="0">==请选择==</option>
	            <c:forEach var="ctg" items="${ctgs}">
	               <option value="${ctg.ctgId}" <c:if test="${param['qryBookCtg']==ctg.ctgId}">selected</c:if>>${ctg.ctgName}</option>
	            </c:forEach>
              </select>&nbsp;&nbsp;<br />
            出版年份： <input type="text" style="border: 1px solid #39c;" size="2" name="qryBookPubYearLeft"value="${param['qryBookPubYearLeft']}"/>
          --&nbsp;<input type="text" style="border: 1px solid #39c;" size="2" name="qryBookPubYearRight"value="${param['qryBookPubYearRight']}"/>&nbsp;&nbsp;
          
               价格：    <span class="linkspan" onclick="PriceSequence('up')">升序</span>&nbsp;
          <span class="linkspan" onclick="PriceSequence('down')">降序</span>&nbsp;
               
          <input type="text" style="border: 1px solid #39c;" size="2" name="qryBookPriceLeft"value="${param['qryBookPriceLeft']}"/>
          --&nbsp;<input type="text" style="border: 1px solid #39c;" size="2" name="qryBookPriceRight"value="${param['qryBookPriceRight']}"/>
       <input style="margin-left: 500px" type="submit" value="查询">
     </div>
     </form>
    <table class="listable" cellspacing=0 cellpadding=0 border=0>
       <thead>
         <tr>
           <th nowrap="nowrap">封 面</th>
           <th nowrap="nowrap">编 号</th>
           <th nowrap="nowrap">名 称</th>
           <th nowrap="nowrap">类 别</th>
           <th nowrap="nowrap">单 价</th>
           <th nowrap="nowrap">作 者</th>
           <th nowrap="nowrap">出版单位</th>
           <th nowrap="nowrap">出版日期</th>
           <th nowrap="nowrap">相关操作</th>
         </tr>          
       </thead>
       <tbody>
          <c:forEach items="${page.pageContent}" var="book">
	          <tr bgColor="#EBF7CC">
	            <td>
	             <img onclick="location.href='<c:url value="/bookMgr?act=showcover&bookcode=${book.bookCode}"/>';"
                       title="点图片查看大图"
                       style="width:50px; height:50px;" 
                       src="<c:url value="/bookMgr?act=showcover&bookcode=${book.bookCode}"/>">
                  </img>
	            </td>
	            <td nowrap="nowrap">
	              ${book.bookCode}
                </td>
	            <td nowrap="nowrap">${book.bookName}</td>
	            <td nowrap="nowrap">${book.ctg.ctgName}</td>
	            <td nowrap="nowrap">${book.bookPrice}</td>
	            <td>${book.bookAuthor}</td>
	            <td nowrap="nowrap">${book.bookPublisher}</td>
	            <td nowrap="nowrap"><fmt:formatDate pattern="yyyy-MM-dd" value="${book.bookPubDate}"/></td>
                <td>
                  <span title="点击修改[${book.bookName}}]图书信息" class="linkSpan" onclick="updateBook('${book.bookCode}');">修改</span>
                  <span title="点击删除[${book.bookName}}]图书信息" class="linkSpan" onclick="removeBook('${book.bookCode}','${book.bookName}')">删除</span>
                </td>
	          </tr>
          </c:forEach>
       </tbody>
    </table>
       <div id="pageinfo" style="float:right; margin:5px; padding-right:3px;">
		            共${page.totalRecNum}条, 当前显示${page.startIndex+1}-${page.endIndex}条, 第${page.pageNo}/${page.totalPageNum}页
		           |
		           <c:if test="${page.pageNo>1}">
		             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.prePage}">
		             <span class="linkspan" onclick="doQuery(${page.pageNo-1})">上一页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.nextPage}">
		             <span class="linkspan" onclick="doQuery(${page.pageNo+1})">下一页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.pageNo!=page.totalPageNum}">
		             <span class="linkspan" onclick="doQuery(${page.totalPageNum})">末页</span>&nbsp;
		           </c:if>
		           |
		            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();"/> 页
		           <button onclick="doQuery($('pageNo').value);"> 跳 转 </button>		           		           	           	              
		        </div>
	     </div>  
    </c:if>
	<c:if test="${empty page.pageContent}">
       <center>
        <div id="noRecord" style="margin-top:80px;width:30%;height:70px;border:1px solid #c1cdd8;text-align:center;">
          <span style="margin-top:20px;color:red;">没有符合条件的图书信息被找到!</span>
          <br/>
          <br/>
          <button onclick="history.go(-1);"> 返 回 </button>
        </div>
       </center>
     </c:if> 
     
     <c:if test="${not empty errMsg}">
      <script type="text/javascript">
        alert('${errMsg}');
      </script>
       <c:remove var="errMsg"/>
     </c:if>
  </body>
</html>
